package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.ConsumeRecordDto;
import edu.suda.xsap.dto.convert.ConsumeRecordConvert;
import edu.suda.xsap.entity.ConsumeRecord;
import edu.suda.xsap.service.ConsumeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.suda.xsap.mapper.ConsumeRecordMapper;
import java.util.List;
@Service
public class ConsumeRecordServiceImpl implements ConsumeRecordService {
@Autowired
private ConsumeRecordMapper consumeRecordMapper;
@Autowired
private ConsumeRecordConvert consumeRecordConvert;
    @Override
    public void save(ConsumeRecord consumeRecord) {
        consumeRecordMapper.save(consumeRecord);
    }

    @Override
    public void update(ConsumeRecord consumeRecord) {
        consumeRecordMapper.update(consumeRecord);
    }

    @Override
    public ConsumeRecordDto findById(Integer id) {
        return consumeRecordConvert.toDto(consumeRecordMapper.findById(id));
    }

    @Override
    public List<ConsumeRecordDto> findAll() {
        return consumeRecordConvert.toDtoList(consumeRecordMapper.findAll());
    }
}
